package com.example.pre.tools;

/**
 * 
 * @ClassName: Pager.java
 * @Description: 分页工具类
 *
 */
public class Pager {
	/**
	 * 
	 * @param pageIndex 页下标从1开始
	 * @param pageSize  分页大小
	 * @param total     总条数
	 */
	public Pager(Integer pageIndex, Integer pageSize, Integer total) {
		this.pageIndex = pageIndex;
		this.pageSize = pageSize;
		this.total = total;
		if (total > 0 && pageSize != null) {
			this.pageTotal = (int) Math.ceil((1.0 * total / pageSize));
		}
	}

	public Pager() {

	}

	public Integer getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(Integer pageIndex) {
		this.pageIndex = pageIndex;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public Integer getPageTotal() {
		return pageTotal;
	}

	public void setPageTotal(Integer pageTotal) {
		this.pageTotal = pageTotal;
	}

	/**
	 * 页下标
	 */
	public Integer pageIndex;
	/**
	 * 每页大小
	 */
	public Integer pageSize;
	/**
	 * 查询后返回带的总数据大小
	 */
	public Integer total = 0;
	/**
	 * 查询出的总页数
	 */
	public Integer pageTotal = 0;

	@Override
	public String toString() {
		return "Pager [pageIndex=" + pageIndex + ", pageSize=" + pageSize + ", total=" + total + ", pageTotal="
				+ pageTotal + "]";
	}

}
